package doublepoint;

/**
 * @Author: 海琳琦
 * @Date: 2022/2/3 21:51
 * https://leetcode-cn.com/problems/reverse-linked-list/
 */
public class ReverseList {

    class ListNode {
        int val;
        ListNode next;
        public ListNode() {

        }

        public ListNode(int val) {
            this.val = val;
        }

        public ListNode(int val, ListNode next) {
            this.val = val;
            this.next = next;
        }
    }
    public ListNode reverseList(ListNode head) {
        ListNode preNode = null;
        ListNode curNode = head;
        ListNode temp;
        while (curNode != null) {
            temp = curNode.next;
            curNode.next = preNode;
            preNode = curNode;
            curNode = temp;
        }
        return head;
    }

    public static void main(String[] args) {

    }
}
